/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.general.be;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author OscarA
 */
@Entity
@Table(name = "gen_provincia")
@NamedQueries({@NamedQuery(name = "Provincia.findAll", query = "SELECT p FROM Provincia p"), @NamedQuery(name = "Provincia.findByProCodigo", query = "SELECT p FROM Provincia p WHERE p.proCodigo = :proCodigo"), @NamedQuery(name = "Provincia.findByProNombre", query = "SELECT p FROM Provincia p WHERE p.proNombre = :proNombre")})
public class Provincia implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "pro_codigo", nullable = false)
    private Integer proCodigo;
    @Basic(optional = false)
    @Column(name = "pro_nombre", nullable = false, length = 30)
    private String proNombre;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "proCodigo", fetch = FetchType.LAZY)
    private List<Distrito> distritoCollection;
    @JoinColumn(name = "dep_codigo", referencedColumnName = "dep_codigo", nullable = false)
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Departamento depCodigo;

    public Provincia() {
    }

    public Provincia(Integer proCodigo) {
        this.proCodigo = proCodigo;
    }

    public Provincia(Integer proCodigo, String proNombre) {
        this.proCodigo = proCodigo;
        this.proNombre = proNombre;
    }

    public Integer getProCodigo() {
        return proCodigo;
    }

    public void setProCodigo(Integer proCodigo) {
        this.proCodigo = proCodigo;
    }

    public String getProNombre() {
        return proNombre;
    }

    public void setProNombre(String proNombre) {
        this.proNombre = proNombre;
    }

    public List<Distrito> getDistritoCollection() {
        return distritoCollection;
    }

    public void setDistritoCollection(List<Distrito> distritoCollection) {
        this.distritoCollection = distritoCollection;
    }

    public Departamento getDepCodigo() {
        return depCodigo;
    }

    public void setDepCodigo(Departamento depCodigo) {
        this.depCodigo = depCodigo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (proCodigo != null ? proCodigo.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Provincia)) {
            return false;
        }
        Provincia other = (Provincia) object;
        if ((this.proCodigo == null && other.proCodigo != null) || (this.proCodigo != null && !this.proCodigo.equals(other.proCodigo))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.cip.esymons.general.be.Provincia[proCodigo=" + proCodigo + "]";
    }

}
